/* Plot0.do (STATA)
	Plot relative prices and quantities.
	by Ralph Koijen & Motohiro Yogo */

#delimit ;
clear all;
set more off;
set type double;
set scheme s1mono;

cap log close;
log using Plot0, replace;

/* Define local and global variables */

local path = "../../figures";

local clist = "^(Germany|Japan|Switzerland|United Kingdom|United States)$";


/* Load data */

u year Name type maturity yield Lmb Lrealfx Lbook Iycounter_euro
	if regexm(Name,"`clist'") & Iycounter_euro
	using "../1 Data/Data4", clear;

/* Construct relative prices and quantities */

sort year type Name;

by year type: gen Ryield = yield[_N]-yield if Name[_N]=="United States";

foreach var of varlist Lmb Lbook {;
	by year type: gen R`var' = `var'-`var'[_N] if Name[_N]=="United States";
};

drop if Name=="United States";

/* Demean variables */

foreach var of varlist Lrealfx Ryield RLmb RLbook {;
	egen M`var' = mean(`var'), by(Name type);

	replace `var' = `var'-M`var';

	drop M`var';
};

/* Report in percent */

replace Ryield = 100*Ryield;

/* Specify panel labels */

replace Name = "A. Euro" if Name=="Germany" & type==1;
replace Name = "A. Germany" if Name=="Germany" & type>=2;
replace Name = "B. Japan" if Name=="Japan";
replace Name = "C. Switzerland" if Name=="Switzerland";
replace Name = "D. United Kingdom" if Name=="United Kingdom";

/* Figure: Short-term rate vs. quantity */

format year %tyYY;

twoway (scatter Ryield RLbook, m(Sh) mc(gray) msize(vlarge) mlabel(year) mlabp(0))
	(lfit Ryield RLbook, lc(black))
	if type==1,
	by(Name, legend(off) note(""))
	ylabel(-4(2)4, angle(0))
	xlabel(-.8(.4).8)
	ytitle("Short-term rate (%, US minus foreign)")
	xtitle("Log face value (foreign minus US)")
	xsize(6) ysize(6);

/* Output figure */

graph export "`path'/price_quantST.eps", replace;

reg Ryield RLbook if type==1, robust;

/* Figure: Long-term yield vs. quantity */

twoway (scatter Ryield RLbook, m(Sh) mc(gray) msize(vlarge) mlabel(year) mlabp(0))
	(lfit Ryield RLbook, lc(black))
	if type==2,
	by(Name, legend(off) note(""))
	ylabel(-2(1)2, angle(0))
	xlabel(-.4(.2).4)
	ytitle("Long-term yield (%, US minus foreign)")
	xtitle("Log face value (foreign minus US)")
	xsize(6) ysize(6);

graph export "`path'/price_quantLT.eps", replace;

reg Ryield RLbook if type==2, robust;

/* Figure: Equity price vs. quantity */

twoway (scatter RLmb RLbook, m(Sh) mc(gray) msize(vlarge) mlabel(year) mlabp(0))
	(lfit RLmb RLbook, lc(black))
	if type==3,
	by(Name, legend(off) note(""))
	ylabel(-.8(.4).4, angle(0)) 
	xlabel(-.4(.2).4)
	ytitle("Log market-to-book (foreign minus US)")
	xtitle("Log book value (foreign minus US)")
	xsize(6) ysize(6);

/* Output figure */

graph export "`path'/price_quantE.eps", replace;

reg RLmb RLbook if type==3, robust;

log close;
